home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 10978 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.4 KB

  1. Path: inforamp.net!ts28-10
  2. From: rmorin@inforamp.net (Randy Charles Morin)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: passing filenames by ref
  5. Date: Tue, 12 Mar 96 04:00:34 GMT
  6. Organization: MiddleWorld SoftWare
  7. Message-ID: <4i2sth$nfn@sam.inforamp.net>
  8. References: <HpARxor+BgbR090yn@delta1.deltanet.com>
  9. NNTP-Posting-Host: ts28-10.tor.inforamp.net
  10. X-Newsreader: News Xpress Version 1.0 Beta #4
  11.  
  12. In article <HpARxor+BgbR090yn@delta1.deltanet.com>,
  13.    tdb@delta1.deltanet.com (Tom D. Baccanti) wrote:
  14. >I am a new blind student learning c++ and am having some trouble
  15. >understanding the way to pass in a filename by reference.  If I could get a
  16. >simple example to look at I will understand it better.  If this is too basic
  17. >of a question please disregard.  And yes I am using a screen reader and
  18. >compiling from the dos command line with borland 4.52.  Thanks, Tom Baccanti
  19.  
  20. Most people use char * to represent a string.  In this case, passing a string 
  21. by reference makes no sense.  In the C++ idiom, you should you a string class, 
  22. like String in the Borland libraries.  This class encapsulates the meaning of 
  23. a string allowing you to perform powerful string handling functions like the 
  24. following...
  25.  
  26. main ()
  27. {
  28.     string str="Temp";
  29.     if (str.compare("temporary")) return;
  30.     str.append("orary");
  31.     str.to_lower();
  32.     f(str);
  33. }
  34.  
  35. void f(string &str)
  36. {
  37.     if (str.compare("temporary")) return;
  38.     str.to_upper();
  39. };
  40.  
  41. I hope this helps.
  42.  
  43. Agrivar
  44.